package STUDENT.NGUYENHUUTHANG.STRUCTURE_PROGRAMMING.EXAMPLES;

import java.util.Scanner;

public class giaipt {

	public static void main(String[] args) {
		System.out.println("Ban hay nhap cac he so a,b,c cua pt bac 2 ax2+bx+c=0");
		System.out.println("a=");
		Scanner sc = new Scanner(System.in);
		String temp1 = sc.nextLine();
		if (temp1.isEmpty()) {
			System.out.println("Ban chua nhap gia tri cua a");
		} else
			System.out.println("b=");
		String temp2 = sc.nextLine();
		if (temp2.isEmpty()) {
			System.out.println("Ban chua nhap gia tri cua b");
		} else
			System.out.println("c=");
		String temp3 = sc.nextLine();
		if (temp3.isEmpty()) {
			System.out.println("Ban chua nhap gia tri cua c");
		} else {
			double a = Double.parseDouble(temp1);
			double b = Double.parseDouble(temp2);
			double c = Double.parseDouble(temp3);
			if (a == 0) {
				System.out.println("Khong phai la phuong trinh bac 2");
			}
			
			/*
			 * if (a == 0 && b==0 && c==0){ System.out.println(
			 * "Phuong trinh co vo so nghiem"); }
			 */

			else {
				double delta = b * b - 4 * a * c;
				if (delta >= 0) {
					if (delta == 0) {
						System.out.println("Phuong trinh co nghiem:");
						System.out.println("x=" + (-b / (2 * a)));
					}
					if (delta > 0) {
						System.out.println("Phuong trinh co nghiem:");
						double x1 = ((-b + Math.sqrt(delta)) / (2 * a));
						double x2 = ((-b - Math.sqrt(delta)) / (2 * a));
						System.out.println("x1= " + x1);
						System.out.println("x2= " + x2);
					}
				} else
					System.out.println("Phuong trinh vo nghiem!");
			}

		}
	}

}
